solid_agent 0.2.0: tool persistence + enrichment, ToolCache, HasMemory, ModelPricing, AgentRun - #4
Merged
Conversation
Conversations persisted through HasContext only recorded the final
assistant message; the tool/MCP roundtrips in the response's message
stack were dropped, so downstream views (like the ActiveAgents
Interactions dashboard) couldn't show what an agent actually did.
- HasContext now persists each tool-result message to the context via
add_tool_message (already part of the install generator's
AgentContext), deduped by tool_call_id so shared message stacks in
multi-turn conversations don't duplicate rows. Contexts without
add_tool_message are skipped, keeping the change drop-in for
existing apps.
- New SolidAgent::ToolCache caches tool/MCP/service results by
(tool, normalized args) with a TTL, backed by Rails.cache out of
the box and by any read/write store elsewhere. Error-shaped results
({ error: ... }) are never cached, and replayed hashes are tagged
cached: true so callers can tell a replay from a fresh call.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
Bakes a memory concern into solid_agent: agents persist a summary list they decide when to read/write while interacting with tools, other agents, and users. - SolidAgent::HasMemory exposes save_memory/recall_memory as function-calling tool definitions plus matching instance methods, so a provider's tool calls route straight to persistent memory. The memory subject defaults to params[:memorable], falling back to the HasContext contextable. - Memory is scoped to (memorable subject, scope) rather than the agent class, so any agent operating on the same subject shares it — a handoff channel between agents, with source_agent provenance on every entry and AgentMemory#to_prompt for instruction injection. - The install generator now creates agent_memories / agent_memory_entries tables and AgentMemory/AgentMemoryEntry models implementing the duck-typed contract, so existing Rails apps get memory out of the box alongside contexts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
|
⏳ Superconductor is working — View implementation I'll get back to you soon! |
- HasContext#persist_tool_messages_to_context now consults an overridable
tool_invocations hook: executors that run tools server-side return
invocation records ({tool_call_id:, name:, arguments:, duration_ms:})
which are matched to response tool messages by tool_call_id, else by
position (Ollama's tool messages carry neither name nor id). Persisted
rows then carry the call's arguments and timing. Enrichment keywords
are only passed when the context's add_tool_message accepts them, so
models generated before this change keep working.
- Install template AgentContext#add_tool_message gains arguments:/
duration_ms: (writes tool_arguments + metadata duration_ms), matching
what the enrichment path passes.
- SolidAgent::ModelPricing: token counts -> estimated USD. RubyLLM
registry rates when available, static pattern table fallback, blended
default. Mock models price free (pattern ordered before real models so
mock-gpt-4o-mini doesn't bill at gpt-4o rates). The template's
AgentGeneration#estimated_cost uses it when no explicit rates given.
- README: document all seven concerns + ToolCache/ModelPricing/
AgentManifest and the solid_agent:install generator (it previously
described three concerns and omitted install entirely).
215 runs, 496 assertions, 0 failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
HasMemory, ToolCache, ModelPricing, and enriched tool persistence are a minor-version feature set — and consumers gate on the version to know whether HasContext persists tool details itself. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
The install generator now ships an agent_runs table + AgentRun model —
the platform-proven shape for run orchestration: lifecycle status
(pending/running/complete/failed/cancelled with start!/complete!/fail!/
cancel!), token + duration accounting, trace_id correlation with
contexts/generations/telemetry, and an append-only progress-event
stream (append_event: eid-paired started/done/error events, byte-capped
detail, update_column so the run's own thread appends safely).
SolidAgent::RunFingerprint carries the cohort logic: 8-char instruction
digests and deterministic adjective-noun codenames ("calm-heron") so
configuration cohorts read as names instead of hex.
220 runs, 0 failures.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The 0.2.0 feature set — solid_agent persists and caches the full agent interaction stream out of the box, for any Rails app using activeagent:
HasContextpersists every tool-result message from the response's message stack to the context viaadd_tool_message(deduped bytool_call_id), so conversations record the full agent ↔ tool/MCP exchange, not just the final assistant text. Contexts withoutadd_tool_messageare skipped, keeping it drop-in for existing apps.tool_invocationsto supply their invocation records ({tool_call_id:, name:, arguments:, duration_ms:});HasContextmatches them to response tool messages bytool_call_id, else by position (Ollama's tool messages carry neither name nor id), so persisted rows carry arguments and timing. Enrichment keywords are only passed when the context'sadd_tool_messageaccepts them — models generated before this change keep working.SolidAgent::ToolCache— caches tool/MCP/service results by(tool, normalized args)with a TTL, backed byRails.cache(any read/write store can be injected). Error-shaped results ({ error: ... }) are never cached; replays are taggedcached: true.SolidAgent::HasMemory— an agent-curated summary list the model reads/writes viasave_memory/recall_memoryfunction-calling tools. Memory is scoped to a subject record (memorable,scope) rather than the agent class, so agents operating on the same subject share it — a handoff channel withsource_agentprovenance andAgentMemory#to_promptfor instruction injection.SolidAgent::ModelPricing— token counts → estimated USD (RubyLLM registry rates when available, static pattern-table fallback; mock models price free). The generatedAgentGeneration#estimated_costuses it.AgentRun— durable run records installed by the generator: lifecycle status, append-only progress events (append_event), trace_id correlation, token/duration accounting, andSolidAgent::RunFingerprintinstruction cohorts with deterministic codenames ("calm-heron").solid_agent:installgenerator).Test plan
test/solid_agent/tool_cache_test.rb,has_memory_test.rb,has_context_tool_messages_test.rb,model_pricing_test.rb,run_fingerprint_test.rb🤖 Generated with Claude Code
https://claude.ai/code/session_01B5PaDq3uaUWuA8UW4K7siP